<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center faultdispatch_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub faultdispatch_fd0_0'>
          <view class='flex flex-wrap align-center faultdispatch_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  faultdispatch_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='faultdispatch_fd0_0_c1_c0'>故障报修</text>
          </view>
          <view class='flex flex-wrap align-center justify-end faultdispatch_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout faultdispatch_fd1_0_c6">
        <view class='flex flex-direction align-stretch faultdispatch_fd1_0'>
          <view class='flex align-stretch justify-between faultdispatch_fd1_0_c0'>
            <view class='flex flex-wrap align-center'>
              <text class='faultdispatch_fd1_0_c0_c0_c0'>设备编号</text>
            </view>
            <benben-input class='faultdispatch_fd1_0_c0_c1' type="text" :placeholder="`25855`" confirm-type="done"
              :maxlength="30" placeholder-style="color:#999;font-size:28rpx" :disabled="true" v-model="comdFacCore" />
          </view>
          <view class='flex align-stretch justify-between faultdispatch_fd1_0_c0'
            @click.stop="pickerDiy1656986153485=true">
            <view class='flex flex-wrap align-center'>
              <text class='faultdispatch_fd1_0_c0_c0_c0'>故障发生时间</text>
            </view>
            <benben-input class='faultdispatch_fd1_0_c1_c1' type="text" :placeholder="`请选择时间`" confirm-type="done"
              :disabled="true" :maxlength="30" placeholder-style="color:#999;font-size:28rpx" v-model="malfTime" />
          </view>
          <view class='flex flex-direction align-stretch justify-between faultdispatch_fd1_0_c0'>
            <view class='flex flex-wrap align-center'>
              <text class='faultdispatch_fd1_0_c0_c0_c0'>故障原因描述</text>
            </view>
          </view>
          <view class='flex flex-wrap faultdispatch_fd1_0_c3'>
            <textarea class='flex faultdispatch_input_fd1_0_c3' :placeholder="'请输入'" :adjust-position='true'
              :maxlength="240" :show-num='true' placeholder-style="color:#999;font-size:28rpx" v-model="malfDesc" />
            <template>
              <view class='flex flex justify-end faultdispatch_numberfd1_0_c3_c0'>
                <text class='faultdispatch_numberfd1_0_c3_c0_c0'>{{malfDesc.length}}</text>
                <text class='faultdispatch_numberfd1_0_c3_c0_c0'>/</text>
                <text class='faultdispatch_numberfd1_0_c3_c0_c0'>240</text>
              </view>
            </template>
          </view>
          <view class='flex flex-wrap align-center'>
            <text class='faultdispatch_fd1_0_c4_c0'>故障图片</text>
            <text class='faultdispatch_fd1_0_c4_c1'>最多9张</text>
          </view>
          <benben-images-upload ref="benbenImagesUploadfd1_0_c5" :img-list.sync="imgpath" :img-ids.sync="imgid"
            :is-show-tips='true' :maxlength="9">
            <template #content="{ num, maxlength, isShow, imgList }">
              <view class="flex flex-wrap align-start flex faultdispatch_fd1_0_c5">

                <view v-for="(image, index) in imgList" :key="index"
                  class='flex position-relative faultdispatch_fd1_0_c50'>
                  <text class='fu-iconfont2 position-absolute faultdispatch_fd1_0_c500'
                    @tap.stop="$refs.benbenImagesUploadfd1_0_c5.delImage(index)">&#xE8E7;</text>
                  <image class='faultdispatch_fd1_0_c501'
                    @tap.stop="$refs.benbenImagesUploadfd1_0_c5.previewImage(index)" mode="aspectFill" :src='image'>
                  </image>
                </view>

                <image class='faultdispatch_fd1_0_c51' @tap.stop="$refs.benbenImagesUploadfd1_0_c5.manyChooseImage()"
                  v-if="isShow" mode="aspectFit" :src='STATIC_URL+"297.jpg"'></image>

              </view>
            </template>
          </benben-images-upload>
          <view class='flex flex-wrap align-center faultdispatch_fd1_0_c6'>
            <text class='faultdispatch_fd1_0_c4_c0'>故障视频</text>
            <text class='faultdispatch_fd1_0_c4_c1'>最多1张</text>
          </view>
          <view class="upload position-relative padding-bottom-lg">
            <benben-video-upload ref="upload1688780691866" :src.sync="uploadvideo" :video-id.sync="uploadvideo"
              :poster.sync='poster' :name.sync="uploadvideoname" isShowClean='true'>
              <template v-slot="{src, poster}">
                <view class='flex position-relative PublishtransferPurchase_fd1_2_c1'>
                  <image class='PublishtransferPurchase_fd1_2_c1_c0_image' mode="aspectFill"
                    @tap="$refs.upload1688780691866.previewVideo()" :src="poster?poster:STATIC_URL+'224.png'">
                  </image>

                  <text class='fu-iconfont2 position-absolute PublishtransferPurchase_fd1_2_c1_c0_icon'
                    @tap="$refs.upload1688780691866.delVideo()" v-if="src">&#xE8E7;</text>

                </view>
              </template></benben-video-upload>
          </view>
        </view>
        <button class='faultdispatch_fd1_1' @tap.stop="submitforcertificationFunc()">提交</button>
      </view>

      <!---flex布局flex布局结束-->

      <!--选择生日开始 -->
      <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1656986153485" :value.sync='malfTime'
        mode='date' :picker-height='88' :current='true' :mask-show='true' fields='day' :timeout='true'
        start-year='1920-01-01' end-year='现在'>
        <template #picker-header>
          <view class='flex flex-wrap align-center justify-between myInfo_picker2_0'>
            <text class='myInfo_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
            <text class='myInfo_picker2_0_c1'>选择时间</text>
            <text class='myInfo_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确定</text>
          </view>
        </template>
      </benben-picker>
      <!--选择生日结束 -->
    </view>
  </view>
</template>
<script>
  import UploadImage from '@/common/utils/upload-image.js'
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "fd1_0_c3": "",
        "imgid": "",
        "imgpath": [],
        order_sn: '',
        comdFacCore: '',
        malfTime: '', //故障发生时间
        malfDesc: '', //故障描述
        malfImages: '', //图片
        malfVideo: '', //视频
        uploadvideo: '',
        uploadvideoname: '',
        pickerDiy1656986153485: false,
        poster: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        order_sn,
        comdFacCore
      } = options
      if (order_sn !== undefined) this.order_sn = order_sn
      if (comdFacCore !== undefined) this.comdFacCore = comdFacCore
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {},
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {

      //提交认证信息
      async submitforcertificationFunc() {
        console.log('uploadvideo', this.uploadvideo + '?x-oss-process=video/snapshot,t_1000,m_fast')
        if (!validate(this.malfTime, 'require')) {
          this.$message.info('请选择时间');
          return false;
        }
        if (!validate(this.malfDesc, 'require')) {
          this.$message.info('请输入故障描述');
          return false;
        }
        if (this.imgpath.length == 0) {
          this.$message.info('请上传故障图片');
          return false;
        }
        // if (!validate(this.uploadvideo, 'require')) {
        //   this.$message.info('请上传故障视频');
        //   return false;
        // }
        //请求方法
        //数据验证
        let data65051c6e1a706 = await this.$api.dbPost(global.apiUrls.applyMalfRepWay, {
          id: this.order_sn,
          malfTime: this.malfTime, //故障发生时间
          malfDesc: this.malfDesc, //故障描述
          malfImages: this.imgpath.join(','), //图片
          malfVideo: this.uploadvideo, //视频
        });
        if (!data65051c6e1a706) return
        if (data65051c6e1a706.data.code != 0) {
          this.$message.info(data65051c6e1a706.data.msg);
          return
        }



        this.$message.info('提交成功');
        setTimeout(() => {
          this.$urouter.redirectTo(`/pages/ddgl/submitsuccess/submitsuccess`);
        }, 800)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .myInfo_picker2_0_c2 {
    color: var(--benbenbgColor7);
    line-height: 40rpx;
    font-size: 32rpx;
    font-weight: 500;
  }

  .myInfo_picker2_0_c1 {
    font-size: 32rpx;
    font-weight: 400;
    color: #333333;
  }

  .myInfo_picker2_0_c0 {
    line-height: 40rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #BFBFBF;
  }

  .myInfo_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .PublishtransferPurchase_fd1_2_c1_c0_image {
    width: 160rpx;
    height: 160rpx;
  }

  .PublishtransferPurchase_fd1_2_c1_c0_icon {
    top: 0rpx;
    right: 0rpx;
    z-index: 1;
    color: #ff5536;
  }

  .PublishtransferPurchase_fd1_2_c1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
    width: 160rpx;
    height: 160rpx;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .faultdispatch_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .faultdispatch_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .faultdispatch_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .faultdispatch_fd0_0_c0 {
    width: 120rpx;
  }

  .faultdispatch_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .faultdispatch_fd1_1 {
    background: var(--benbenbgColor7);
    border-radius: 44rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
    position: fixed;
    bottom: calc(60rpx + var(--window-bottom));
    right: 32rpx;
    z-index: 2;
  }

  .faultdispatch_fd1_0_c7_image {
    width: 160rpx;
    height: 160rpx;
  }

  .faultdispatch_fd1_0_c7 {
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .faultdispatch_fd1_0_c6 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .faultdispatch_fd1_0_c52 {
    font-size: 32rpx;
    color: #d5d5d5;
  }

  .faultdispatch_fd1_0_c51 {
    width: 150rpx;
    height: 150rpx;
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .faultdispatch_fd1_0_c501 {
    width: 150rpx;
    height: 150rpx;
  }

  .faultdispatch_fd1_0_c500 {
    top: 0rpx;
    right: 0rpx;
    z-index: 10;
    color: #ff5536;
  }

  .faultdispatch_fd1_0_c50 {
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .faultdispatch_fd1_0_c5 {
    width: 630rpx;
    padding: 24rpx 24rpx 0rpx 0;
  }

  .faultdispatch_fd1_0_c4_c1 {
    color: rgba(153, 153, 153, 1);
    font-size: 24rpx;
    margin: 0rpx 0rpx 0rpx 12rpx;
  }

  .faultdispatch_fd1_0_c4_c0 {
    font-size: 32rpx;
    font-weight: 600;
    color: #333;
  }

  .faultdispatch_numberfd1_0_c3_c0_c0 {
    color: var(--benbenFontColor0);
  }

  .faultdispatch_numberfd1_0_c3_c0 {
    width: 100%;
    font-size: 24rpx;
    color: #FFFFFF;
    line-height: 46rpx;
    font-weight: 400;
  }

  .faultdispatch_input_fd1_0_c3 {
    width: 654rpx;
    height: 100rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
    white-space: pre-wrap;
  }

  .faultdispatch_fd1_0_c3 {
    background: #F8F9FD;
    width: 650rpx;
    border-radius: 10rpx 10rpx 10rpx 10rpx;
    padding: 10rpx 10rpx 0rpx 16rpx;
    margin: 24rpx 0rpx 24rpx 0rpx;
  }

  .faultdispatch_fd1_0_c1_c1 {
    font-size: 32rpx;
    font-weight: 400;
    color: #333;
    height: 88rpx;
    line-height: 88rpx;
    text-align: right;
  }

  .faultdispatch_fd1_0_c0_c1 {
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
    height: 88rpx;
    line-height: 88rpx;
    text-align: right;
  }

  .faultdispatch_fd1_0_c0_c0_c0 {
    font-size: 28rpx;
    font-weight: 600;
    color: #333;
  }

  .faultdispatch_fd1_0_c0 {
    border-bottom: 1px solid #eee;
    line-height: 88rpx;
    height: 88rpx;
  }

  .faultdispatch_fd1_0 {
    background: var(--benbenbgColor1);
    background-size: 100% auto;
    border-radius: 16rpx;
    padding: 0rpx 32rpx 0rpx 32rpx;
    margin: 0rpx 24rpx 24rpx 24rpx;
  }
</style>
